<template>
	<view class="container">
		<view class="printer-list">
			<view class="printer-item" v-for="(item, index) in brandList" :key="index" @tap="addStorePrinter(item,1)">
				<image :src="item.icon" mode="aspectFit"></image>
				<text class="printer-name">{{ item.print_name }}</text>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		brands
	} from "@/api/userApi/user.js"
	export default {
		data() {
			return {
				brandList: []
			}
		},
		methods: {
			getBrands() {
				brands().then(res => {
					if (res.code == 200) {
						this.brandList = res.data
					}
				})
			},
			addStorePrinter(val, type) {
				uni.navigateTo({
					url: `/pagesUser/addStorePrinter/addStorePrinter?val=${JSON.stringify(val)}&type=${type}`
				});
			}
		},
		onLoad() {
			this.getBrands()
		}
	}
</script>

<style lang="scss">
	page {
		background: #f5f5f5;
	}

	.container {
		padding: 20rpx;

		.printer-list {
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;

			.printer-item {
				width: 340rpx;
				height: 200rpx;
				background-color: #fff;
				border-radius: 10rpx;
				margin-bottom: 20rpx;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
				padding: 20rpx 0rpx;

				.image {
					width: 120rpx;
					height: 120rpx;
					margin-bottom: 10rpx;
				}

				.printer-name {
					font-size: 28rpx;
					color: #333;
					margin-top: 10rpx;
				}
			}
		}
	}
</style>